Skip to content

Add message template support for alert component#17516

Merged
balloob merged 12 commits intohome-assistant:devfrom
thoscut:dev
Nov 1, 2018
Merged

Add message template support for alert component#17516
balloob merged 12 commits intohome-assistant:devfrom
thoscut:dev

Conversation

@thoscut
Copy link
Copy Markdown
Contributor

@thoscut thoscut commented Oct 16, 2018

Description:

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#6859

Example entry for configuration.yaml (if applicable):

  plant_office:
    name: Plant in office needs help
    entity_id: plant.plant_office
    state: 'problem'
    repeat:
      - 60
      - 720
    message: "{{ states.plant.plant_office }} ({{ state_attr('plant.plant_office', 'problem') }})"
    notifiers:
      - telegram_receiver

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If user exposed functionality or configuration variables are added/changed:

if self._message_template is not None:
message = self._message_template.async_render()
else:
message = '{0}'.format(self._name)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason to format, just message = self._name will do.

@balloob
Copy link
Copy Markdown
Member

balloob commented Oct 17, 2018

Looks good! Ok to merge when a test has been added.

self._setup_notify()

config = deepcopy(TEST_CONFIG)
config[alert.DOMAIN][NAME][alert.CONF_MESSAGE_TEMPLATE] = "{{ states.sensor.test.entity_id }}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (102 > 79 characters)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation contains tabs
unexpected indentation
TabError: inconsistent use of tabs and spaces in indentation

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation contains tabs
indentation contains mixed spaces and tabs
blank line contains whitespace

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation contains mixed spaces and tabs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation contains tabs
indentation contains mixed spaces and tabs
blank line contains whitespace

@thoscut thoscut force-pushed the dev branch 4 times, most recently from a6634f4 to b4ad138 Compare October 18, 2018 21:09
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation contains mixed spaces and tabs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line contains whitespace
indentation contains mixed spaces and tabs
indentation contains tabs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line contains whitespace
indentation contains mixed spaces and tabs
indentation contains tabs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line under-indented for visual indent
indentation contains mixed spaces and tabs
indentation contains tabs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trailing whitespace

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation contains mixed spaces and tabs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line under-indented for visual indent
indentation contains mixed spaces and tabs
indentation contains tabs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trailing whitespace

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trailing whitespace

@thoscut
Copy link
Copy Markdown
Contributor Author

thoscut commented Oct 31, 2018

I updated the component to support templates for both, message and done_message. For legacy support, the message is optional and the name taken instead, like it was before.
Is there a common practice for marking this legacy support for removal/deprecated in a later release?

@MartinHjelmare
Copy link
Copy Markdown
Member

Is this PR clashing with #17616?

@balloob balloob merged commit bfa86b8 into home-assistant:dev Nov 1, 2018
@ghost ghost removed the in progress label Nov 1, 2018
@balloob balloob mentioned this pull request Nov 9, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants